<template>
    <div class="brandCollect">
       <div class="container-header">
            <router-link  to="/userInfo" class="header-left vip-icon icon-back" tag="div"></router-link>
            <div class="header-middle">我的特卖</div>
            <router-link to="/home" tag="div" class="header-right vip-icon icon-home"></router-link>
        </div>

        <div class="container-tab">
            <ul class="container-tab-uls">
                <router-link to="/myCollect" tag="li">商品收藏</router-link>
                <li class="con">品牌收藏</li>
                <li>我的足迹</li>
            </ul>
        </div>

        <div class="filterbar-container">
            <ul>
                <li :class="{'con':index == i}" v-for="(item,index) in lists" :key="index" @click="i = index">{{item}}</li>
                
            </ul>
        </div>
        
        <!-- 品牌收藏 -->
        <div class="brand-content" v-if="brandList" >
            <div class="content-header" >
                    <router-link to="/productDetail" tag="div"><img :src="brandList.brandImage"  alt=""></router-link>
                    <span>{{brandList.shopName}}</span>
                    <i>有优惠</i>
                    <i>上新</i>
            </div>
            <div class="content-item">
                <div class="lists" v-for="count in 3" :key="count">
                    <div class="image"><img :src="brandList.image" alt=""></div>
                    <span><span>超值</span></span>
                    <div class="detail">
                        <div class="price">特卖价 </div>
                        <i>￥{{brandList.price.minPrice | minPriceInt}}</i>
                    </div>
                </div>
                
            </div>
        </div>

        <div class="empty" v-if="!brandList">
            <van-empty description="请添加收藏内容" />
        </div>
    </div>
</template>

<script>
import {getCollectProduct} from "../api/collect.js";
    export default {
        name:"brandCollectView",
        data() {
            return {
                i:0,
                lists:["全部","优惠中","上新","已降价"],
                brandList:null,
                id:null
            };
        },
         methods:{
            // 调用json数据
            getCollectProductFun(){
                getCollectProduct().then(data=>{
                    console.log(data);
                    let index = window.localStorage.getItem("brand");
                    this.brandList = data[index];
                    console.log(this.brandList);
                })
            }
        },
        mounted(){
            this.getCollectProductFun();
            // this.id = window.localStorage.getItem("product1");
            // console.log(this.id);
        },
         filters:{
          "minPriceInt":function(value){
            return parseInt(value)
          }
        }
    }
</script>

<style lang="scss" scoped>
.brandCollect{
    .container-header{
        width: 100%;
        height: 44px;
        display: flex;
        align-items: center;
        .header-left{
            width: 56px;
            height: 44px;
            text-align: center;
            line-height: 44px;
            font-size: 20px;
        }

        .header-middle{
            text-align: center;
            line-height: 44px;
            font-size: 18px;
            flex: 1;
        }
        .header-right{
            font-size: 20px;
            width: 56px;
            height: 44px;
            text-align: center;
            line-height: 44px;
        }
    }
    .container-tab{
        .container-tab-uls{
            width: 100%;
            height: 40px;

            display: flex;
            justify-content: space-evenly;

            li{
                width: 30%;
                text-align: center;
                height: 40px;
                font-size: 16px;
                line-height: 40px;
                border-bottom: 2px solid transparent;
                box-sizing: border-box;
                color: #585c64;
                &.con{
                    border-bottom: 2px solid rgb(222, 61, 150);
                    color: rgb(222, 61, 150);
                }
            }
        }
    }
    .filterbar-container{
        width: 100%;
        display: flex;
        ul{
            display: flex;
            justify-content: space-evenly;
            padding: 12.5px 15px;
            box-sizing: border-box;
            li{
                
                margin:0 5px;
                width: 72px;
                height: 25px;
                border-radius: 12.5px;
               overflow: hidden;
               text-align: center;
               line-height: 25px;
               background-color: #f3f4f5;
               border: 1px solid transparent;

               &.con{
                border: 1px solid #f03867;
                color: #f03867;
                background-color: #fff;
               }
            }
        }
    }

    .brand-content{
        margin-top: 8px;
        padding: 0 15px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        border: 1px solid #e7e7e7;
        .content-header{
            height: 60px;
            padding-top: 15px;
            display: flex;
            align-items: center;
            div{
                width: 60px;
                height: 60px;
                border: 1px solid #f3f4f5;
                display: flex;
                justify-content: center;
                align-items: center;
                img{
                    width: 60px;
                    height: 30px;
                }
                margin-right: 10px;
            }
            span{
                font-size: 18px;
                color: #222222;
                flex: 1;
            }
            i{
                text-align: center;
                width: 40px;
                height: 16px;
                background-color: #f3f4f5;
                border-radius: 5px;
                overflow: hidden;
                line-height: 12px;
                font-size: 12px;
                color: #585c64;
                margin-right: 5px;
            }
        }
        .content-item{
            margin-top:15px ;
            display: flex;
            justify-content: space-between;
            width: 100%;
            height: 149px;
            .lists{
                display: flex;
                flex-direction: column;
                align-items: center;
                position: relative;
                .image{
                    width: 107px;
                    height: 107px;

                    img{
                        width: 107px;
                    }
                }

                span{
                    position: absolute;
                    top: 0;
                    right: 0;
                    width: 26px;
                    height: 16px;
                    color:#de3d96 ;
                    text-align: center;
                    line-height: 14px;
                    font-size: 12px;
                    border: 1px solid #de3d96;
                    border-radius: 0 8px;
                    span{
                        display: inline-block;
                        transform: scale(0.8);
                        border:none
                    }
                }

                .detail{
                    margin-top: 8px;
                    display: flex;
                    justify-content: space-between;
                    padding: 0 10px;
                    box-sizing: border-box;
                    align-items: center;
                    .price{
                        background: linear-gradient(270deg,#cb78dc,#de3d96);
                        font-size: 12px;
                        width: 40px;
                        height: 15px;
                        // padding: 0 5px;
                        box-sizing: border-box;
                        text-align: center;
                        line-height: 15px;
                        color: #fff;
                        border-radius: 5px;
                    }
                   i{
                    font-size: 14px;
                    margin-left: 5px;
                   }
                }
            }
        }

    }
    .empty{
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
</style>